﻿namespace Chaliy.Syndication.UnitTests.MediaRss
{
    using Xunit;
    using XunitExt;
    using Chaliy.Syndication.MediaRss;
    using System;

    public class When_Write_Media_Category
    {
        [Fact]
        public void Serializer_Should_Write_Category_Element()
        {
            MediaCategory raiting = new MediaCategory();

            raiting
                .ShouldMatchMedia("/media:category", "Category element SHOULD exists");
        }

        [Fact]
        public void Serializer_Should_Write_Scheme()
        {
            const string etalonScheme = "http://dmoz.org";

            MediaCategory raiting
                = new MediaCategory
                {
                    Scheme = etalonScheme
                };

            raiting
                .ShouldMatchMedia("/media:category/@scheme", "Scheme attribute SHOULD exists")
                .Value.ShouldEqual(etalonScheme);
        }

        [Fact]
        public void Serializer_Should_Not_Write_Yahoo_Scheme()
        {
            const string yahooSheme = "http://search.yahoo.com/mrss/category_schema";

            MediaCategory raiting
                = new MediaCategory
                {
                    Scheme = yahooSheme
                };

            raiting
                .ShouldNotMatchMedia("/media:category/@scheme", "Scheme attribute SHOULD NOT exists");
        }

        [Fact]
        public void Serializer_Should_Not_Write_Empty_Scheme()
        {
            const string emptyScheme = "";

            MediaCategory raiting
                = new MediaCategory
                {
                    Scheme = emptyScheme
                };

            raiting
                .ShouldNotMatchMedia("/media:category/@scheme", "Scheme attribute SHOULD NOT exists");
        }

        [Fact]
        public void Serializer_Should_Write_Category_Value()
        {
            const string etaloneValue = "music/artist/album/song";

            MediaCategory raiting
                = new MediaCategory
                {
                    Value = etaloneValue
                };

            raiting
                .ShouldMatchMedia("/media:category", "Category element SHOULD exists")
                .Value.ShouldEqual(etaloneValue);
        }

        [Fact]
        public void Serializer_Should_Write_Category_Label()
        {
            const string etaloneValue = "Ace Ventura - Pet Detective";

            MediaCategory raiting
                = new MediaCategory
                {
                    Label = etaloneValue
                };

            raiting
                .ShouldMatchMedia("/media:category/@label", "Label attribute SHOULD exists")
                .Value.ShouldEqual(etaloneValue);
        }

        [Fact]
        public void Serializer_Should_Not_Write_Empty_Category_Label()
        {
            const string emptyValue = "";

            MediaCategory raiting
                = new MediaCategory
                {
                    Label = emptyValue
                };

            raiting
                .ShouldNotMatchMedia("/media:category/@label", "Label attribute SHOULD NOT exists");
        }
    }
}
